package com.cw.vo;

import com.cw.common.method.SendCardMsg;
import com.cw.entity.MsgInfo;
import com.cw.entity.TelMessageLog;
import com.cw.entity.WeChatLog;
import com.cw.mapper2.TelMessageMapper;
import com.cw.mapper2.WeChatLogMapper;
import com.cw.service.impl.PatientBedMiddleServiceImpl;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;

public class SendTread implements Runnable {
    private MsgInfo msgInfo;
    @Autowired
    private WeChatLogMapper weChatLogMapper;
    @Autowired
    private TelMessageMapper telMessageMapper;
    PatientBedMiddleServiceImpl patientBedMiddleService = new PatientBedMiddleServiceImpl();

    public void setMsgInfo(MsgInfo msgInfo) {
        this.msgInfo = msgInfo;
    }

    @SneakyThrows
    @Override
    public void run() {
        patientBedMiddleService.setMsg(msgInfo);
        //发送企业微信
        if (!msgInfo.getWechatAccountCode().isEmpty()) {
        //企业微信返回josn消息体
        //调用post发送企业微信消息
            WeChatLog weChatLog = SendCardMsg.send2(msgInfo);
            weChatLogMapper.insert(weChatLog);
            TelMessageLog telMessageLog = SendCardMsg.sendTelMessage(msgInfo,0);
            telMessageMapper.insert(telMessageLog);
        }
    }
}
